package com.icedata.sika.util

import java.util.concurrent.locks.ReadWriteLock

fun ReadWriteLock.read(block: () -> Unit) {
    with(readLock()) {
        lock()
        block()
        unlock()
    }
}

fun ReadWriteLock.write(block: () -> Unit) {
    with(writeLock()) {
        lock()
        block()
        unlock()
    }
}
